<template>
  <el-form label-width="100px">
    <el-form-item label="企业名称">
      <el-input v-model="companyData.name"/>
    </el-form-item>
    <el-form-item label="企业地址">
      <el-input v-model="companyData.address"/>
    </el-form-item>
    <el-form-item label="企业所在楼栋">
      <el-select v-model="companyData.buildingIndex" placeholder="请选择" style="width: 100%">
        <el-option
            v-for="(value, key) in options"
            :key="key"
            :label="value"
            :value="key">
        </el-option>
      </el-select>

    </el-form-item>
    <el-form-item label="联系电话">
      <el-input v-model="companyData.phone"/>
    </el-form-item>
    <el-form-item label="企业类型">
      <el-select v-model="companyData.type" style="width: 100%">
        <el-option label="高新技术企业" value="高新技术企业"></el-option>
        <el-option label="科技型中小企业" value="科技型中小企业"></el-option>
        <el-option label="中小微企业" value="中小微企业"></el-option>
        <el-option label="大规模企业" value="大规模企业"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="认证类型">
      <el-select v-model="companyData.certificationType" multiple style="width: 100%">
        <el-option label="知识产权贯标" value="知识产权贯标"></el-option>
        <el-option label="质量体系认证" value="质量体系认证"></el-option>
        <el-option label="CNSA认证" value="CNSA认证"></el-option>
        <el-option label="未认证" value="未认证"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="员工数量">
      <el-input v-model="companyData.employeeCount"/>
    </el-form-item>
    <el-form-item label="联系人">
      <el-input v-model="companyData.contactPerson"/>
    </el-form-item>
    <el-form-item label="业务类型">
      <el-select v-model="companyData.businessType" class="company" placeholder="请选择" style="width: 100%"
                 value-key="name">
        <el-option
            v-for="(value) in businessName"
            :key="value.uuid"
            :label="value.name"
            :value="value.name">
        </el-option>
      </el-select>

    </el-form-item>
    <el-form-item style="text-align: right">
      <el-button type="primary" @click="addCompany">添加</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import buildingIndex from "../../../common/buildingIndex";
import {AddCompany} from "../../../network/companyApi";

export default {
  data() {
    return {
      options: buildingIndex,
      companyData: {
        name: null,
        address: null,
        phone: null,
        type: null,
        certificationType: null,
        buildingIndex: ''
      },
    }
  },
  methods: {
    addCompany() {
      AddCompany(this.companyData).then(res => {
        console.log(res)
        if (res.code === 2000) {
          this.companyData = {};
          this.$emit("success");
        }
        if (res.code !== 2000) {
          this.$message({
            message: res.message,
            type: "error"
          })
        }
      })
    },
  },
  props: ['businessName'],

}
</script>

<style scoped>
.el-button {
  text-align: right;
}
</style>